package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.shifttype.ShiftTypePubReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.stationweekday.StationWeekdayGetResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.weekdayscheme.*;
import com.zmj.sy.mom.srv.aps.service.WeekdaySchemeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@Api(tags = "工作日方案")
@RestController
@RequestMapping("/weekdayScheme")
public class WeekdaySchemeController {

    private final WeekdaySchemeService weekdaySchemeService;

    /*@ApiOperation("1.5.1 添加并发布")
    @PostMapping("/add")
    public BaseResVo add(@RequestBody WeekdaySchemeAddReqVo reqVo) {
        Integer id = weekdaySchemeService.add(reqVo);

        // 自动发布
        BaseIdReqVo baseIdReqVo = new BaseIdReqVo();
        baseIdReqVo.setId(id);
        weekdaySchemeService.pub(baseIdReqVo);

        return BaseResVo.ok("添加成功");
    }

    @ApiOperation("1.5.2 发布")
    @PostMapping("/pub")
    public BaseResVo pub(@RequestBody BaseIdReqVo reqVo) {
        weekdaySchemeService.pub(reqVo);
        return BaseResVo.ok("发布成功");
    }*/

    @ApiOperation("1.5.3 添加模板")
    @PostMapping("/templateAdd")
    public BaseResVo templateAdd(@RequestBody WeekdaySchemeTemplateAddReqVo reqVo) {
        weekdaySchemeService.templateAdd(reqVo);
        return BaseResVo.ok("添加模板成功");
    }

    @ApiOperation("1.5.4 模板列表")
    @GetMapping("/templateList")
    public BaseListResVo<WeekdaySchemeTemplateListResVo> templateList() {
        return weekdaySchemeService.templateList();
    }

    @ApiOperation("1.5.5 根据模板ID和获取某个时间段的上下班时间")
    @GetMapping("/timeRange")
    public BaseListResVo<WeekdaySchemeTimeRangeResVo> timeRange(WeekdaySchemeTimeRangeReqVo reqVo){
        List<WeekdaySchemeTimeRangeResVo> resVoList = weekdaySchemeService.timeRange(reqVo);
        return BaseListResVo.of(resVoList, WeekdaySchemeTimeRangeResVo.class);
    }

    @ApiOperation("1.5.6 修改模板")
    @PostMapping("/templateEdit")
    public BaseResVo templateEdit(@RequestBody WeekdaySchemeTemplateEditReqVo reqVo) {
        weekdaySchemeService.templateEdit(reqVo);
        return BaseResVo.ok("添加模板成功");
    }

    @ApiOperation("1.5.6 修改模板")
    @PostMapping("/templateEdit2")
    public BaseResVo templateEdit2(@RequestBody WeekdaySchemeTemplateEditReqVo reqVo) {
        weekdaySchemeService.templateEdit2(reqVo);
        return BaseResVo.ok("添加模板成功");
    }

    @ApiOperation("1.5.7 删除")
    @PostMapping("/delete")
    public BaseResVo delete( BaseIdReqVo reqVo) {
        weekdaySchemeService.delete(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("1.5.8 增加休息日")
    @PostMapping("/pubScheme")
    public BaseResVo pubScheme(@RequestBody ShiftTypePubReqVo reqVo) {
        weekdaySchemeService.pubScheme(reqVo);
        return BaseResVo.ok("添加成功");
    }
    @ApiOperation("1.5.9 查看日历休假规则")
    @GetMapping("/getWeekdayRule")
    public StationWeekdayGetResVo getWeekdayRule(BaseIdReqVo reqVo) {
        return weekdaySchemeService.getWeekdayRule(reqVo);
    }

}
